package view.menus;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JMenu;
import javax.swing.JMenuItem;
import controller.CustomEvent;
import controller.EventHandler;
import controller.IOPanelEventHandler;
import controller.MenuEventHandler;
/** * A class to encapsulate the exportation menu  * @author Daniel Bond, Mohammed Abdullah, Gideon Pyzer */
@SuppressWarnings("serial")
public class FileExportMenu extends JMenu{
	private JMenuItem mFileExportXML;
	private JMenuItem mFileExportCSS;
	private JMenuItem mFileExportImage;
	private EventHandler eventHandler;
	private EventHandler IOeventHandler;
	public FileExportMenu(String name)
	{
		super(name);
		mFileExportXML = new JMenuItem("XML");
		mFileExportCSS = new JMenuItem("CSS");
		mFileExportImage = new JMenuItem("Image");
		buildMenu();
		eventHandler = new MenuEventHandler();
		IOeventHandler = new IOPanelEventHandler();
		mFileExportXML.addActionListener(new ActionListener(){
			public void actionPerformed(ActionEvent e){
				CustomEvent event = new CustomEvent("presExport");
				FileExportMenu.this.IOeventHandler.createEvent(event);
			}
		});
		mFileExportCSS.addActionListener(new ActionListener(){
			public void actionPerformed(ActionEvent e){
				CustomEvent event = new CustomEvent("presExportCSS");
				FileExportMenu.this.eventHandler.createEvent(event);
			}
		});
		mFileExportImage.addActionListener(new ActionListener(){
			public void actionPerformed(ActionEvent e){
				CustomEvent event = new CustomEvent("presExportImage");
				FileExportMenu.this.eventHandler.createEvent(event);
			}
		});
	}	/**	 * Adds the options to be available for selection within the export menu	 */
	private void buildMenu()
	{
		this.add(mFileExportXML);
		this.add(mFileExportCSS);
		this.add(mFileExportImage);
	}
}